﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="get_check_in_admin.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.get_check_in_admin" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <%
        DateTime date = DateTime.Parse(Request.QueryString["date"]);
        int get_id = int.Parse(Session["admin_id"].ToString());
        var check_cap = new TblManagerController().FetchAll().Where(x => x.ManagerId == get_id).Single();
        var get_manager_checkin = new TblCheckManagerController().FetchAll().Where(x => DateTime.Parse(x.CheckIn.ToString()).Date == date.Date);
        var sort_checkin = (from p in get_manager_checkin orderby p.Id descending select p);
        foreach (TblCheckManager chk in sort_checkin)
        {
            var get_manager = new TblManagerController().FetchAll().Where(x => x.ManagerId == chk.ManagerId).Single();
            var get_role = new TblManagerRoleController().FetchAll().Where(x => x.RoleId == get_manager.Role).Single();
            string checkout = "";
            int check_hour = DateTime.Parse(chk.CheckIn.ToString()).Hour;
            string work_time = "";

            if (check_hour >= 0 && check_hour <= 12)
            {
                work_time = "Ca sáng";
            }
            if (check_hour >= 13 && check_hour <= 16)
            {
                work_time = "Ca chiều";
            }
            if (check_hour >= 17 && check_hour <= 24)
            {
                work_time = "Ca tối";
            }
            if (chk.CheckOut != null)
                checkout = DateTime.Parse(chk.CheckOut.ToString()).Hour + ":" + DateTime.Parse(chk.CheckOut.ToString()).Minute;
            if (chk.OverTime == true)
            {
                work_time += " (Tăng ca)";
            }
            if (chk.Absent == true)
            {
                work_time = "Vắng";
                if (chk.Accept == true)
                    work_time += " (Có phép)";
            }
    %>
    <tr id="<%=chk.Id %>" class="<%=get_manager.ManagerId %>">
        <td class="checkinout-img w3-hide-small w3-center">
            <span class="check_id w3-hide"><%=chk.Id %></span>
            <img src="../Content/avatar/<%=get_manager.Avatar %>" class="w3-circle" alt="Avatar" />
        </td>
        <td>
            <span><%=get_manager.FullName %></span><br />
            <span class="w3-text-grey w3-hide-small"><%=get_role.RoleName %></span>
        </td>
        <td><%=work_time %></td>
        <%
            if (check_cap.Captain == true && check_cap.Role == get_manager.Role)
            { %>
        <td>
            <%if (chk.Accept == false)
              {
                  if (chk.CheckOut != null)
                  {%>
            <i title="Xác nhận" class="btn_confirm_check checkinout-option-btn fa fa-check w3-hover-text-teal"></i><%}
                  else
                  {%><%}
              }
              else
              { %>
            <i title="Đã xác nhận" class="checkinout-option-btn fa fa-check w3-text-teal"></i>
            <%} %>
            <i title="Chỉnh sửa" class="btn_edit_check checkinout-option-btn fa fa-wrench w3-hover-text-teal"></i>
            <i title="Xóa" class="btn_del_check checkinout-option-btn fa fa-trash w3-hover-text-teal"></i>
        </td>
        <%}
            else
            {
                if (chk.Accept == true)
                {
        %>

       <td>
            <i title="Đã xác nhận" class="checkinout-option-btn fa fa-check w3-text-teal"></i>
        </td>
        <%
                }
            } %>
    </tr>
    <%} %>
</body>
</html>
